<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd" >
<sqlMap namespace="com.uc.training.smadmin.bd.dao.MemberRechargeHistoryDao">

    <!-- 查找充值记录 -->
    <select id="getRechargeHistoryListByMemberId" resultClass="com.uc.training.smadmin.bd.re.MemberRechargeHistoryListRE"
            parameterClass="com.uc.training.smadmin.bd.vo.MemberRechargeHistoryVO">
		 SELECT
            balance,
            status,
            create_time AS createTime
		 FROM t_bd_member_recharge_histroy
         where member_id = #memberId#
         ORDER BY create_time DESC
	</select>

    <!-- 根据会员id获取总记录数 -->
    <select id="getCountByMemberId" resultClass="Integer" parameterClass="Long">
		 SELECT
            count(1)
		 FROM t_bd_member_recharge_histroy
		 where member_id = #memberId#
	</select>

    <!-- 插入 -->
    <insert id="insertMemberRechargeHistory" parameterClass="com.uc.training.smadmin.bd.model.MemberRechargeHistory">
        insert into t_bd_member_recharge_histroy
        (member_id, status, balance, create_emp, modify_emp)
        values (#memberId#,#status#,#balance#,#createEmp#,#modifyEmp#)
        <selectKey keyProperty="id">
            select LAST_INSERT_ID() AS id
        </selectKey>
    </insert>

</sqlMap>